<!--
 * @Author: ZhaoZhiqi
 * @Date: 2022-08-09 09:47:21
 * @LastEditors: ZhaoZhiqi
 * @LastEditTime: 2022-12-13 20:14:21
 * @Description: 文章管理
 * @FilePath: \tuanfeng-admin-front\src\pages\CSI\index.vue
-->
<script setup lang="ts">
import moment from "moment";
import { Search, Plus } from "@element-plus/icons-vue";
import SearchItem from "../../components/SearchItem.vue";
import TableCell from "../../components/TableCell.vue";
import { reactive } from "vue";
import useTable from "./useTable";
import { useRoute } from "vue-router";
import { useRoleStore } from "../../store/role.js";

const path = useRoute().path;
const permissions = useRoleStore().permissions;
const permission = permissions[path] || {};
console.log('permission', permission)

// 查询条件
let filters = reactive({
    pageNo: 1,
    pageSize: 10,
});

const satisfyFilter = (num: number) => {
    console.log(num)
    switch(num) {
        case 5: 
            return '非常满意';
        case 4: 
            return '满意';
        case 3: 
            return '基本满意';
        case 2: 
            return '基本不满意';
        case 1: 
            return '非常不满意';
        default:
            return '-';
    }
}

const colorFilter = (num: number) => {
    console.log(num)
    switch(num) {
        case 5: 
            return '#67C23A';
        case 4: 
            return '#67C23A';
        case 3: 
            return '#E6A23C';
        case 2: 
            return '#E6A23C';
        case 1: 
            return '#F56C6C';
        default:
            return '-';
    }
}

// 列表数据
const { tableData, loading, totalCount, query } = useTable(filters);
</script>

<template>
    <div>
        <el-card class="search-wrapper common-card">
            <div class="search-button-wrapper">
                <el-button type="primary" :icon="Search" auto-insert-space @click="query">查询</el-button>
            </div>
        </el-card>

        <!-- Table -->
        <el-card class="common-card" style="width: 100%">
            <!-- 列表 -->
            <el-table v-loading="loading" :data="tableData" stripe>
                <el-table-column prop="id" label="id" width="80" />
                <el-table-column prop="name" label="姓名" width="150" />
                <el-table-column prop="phone" label="手机号" width="200" />
                <el-table-column prop="evaluatedDept" label="受评部门" />
                <el-table-column prop="content" label="投诉意见">
                    <template #default="scope">{{scope.row.content || '-'}}</template>
                </el-table-column>
                <el-table-column prop="isSatisfy" label="是否满意" width="120">
                    <template #default="scope">
                        <span :style="{color: colorFilter(scope.row.totalEstimate)}">{{ satisfyFilter(scope.row.totalEstimate) }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="createDate" label="创建时间" width="200" />

                <template #empty>
                    <el-empty description="暂无数据"></el-empty>
                </template>
            </el-table>
            <!-- 分页 -->
            <el-pagination style="margin-top: 20px; justify-content: flex-end" background layout="total, sizes, prev, pager, next" :total="totalCount" :default-current-page="1" v-model:current-page="filters.pageNo" v-model:page-size="filters.pageSize"></el-pagination>
        </el-card>
    </div>
</template>

<style lang="less" scoped>
@import url("../../assets/less/common.less");
@import url("../../assets/less/search.less");

.form-item {
    font-size: 14px;
    line-height: 20px;
    color: @color_regular-text;
    margin-bottom: 20px;
    display: flex;
    .form-item-label {
        flex: none;
        width: 100px;
        text-align: right;
        padding-right: 12px;
        box-sizing: border-box;
    }
    .form-item-value {
        flex: none;
        width: 400px;
        padding-right: 20px;
        color: @color_primary-text;
    }
}
</style>